<?php

class CashModel extends Model{
	
	protected $trueTableName  = "csl_cash";//主表
	protected $subTableName   = 'csl_user';//副表
	protected $subTableName2  = 'csl_customer';//副表2
	
	
	function getlist(){
		$subtable = $this->subTableName;
		$subtable2 = $this->subTableName2;
		$cash = $this->select(false);
		$result = $this->table("$cash a")->field("a.*,b.username as u_username,b.name as u_name,c.mobile as c_mobile,c.name as c_name")
		               ->join("$subtable  b on a.uid = b.uid")
		               ->join("$subtable2 c on a.cid = c.cid")
		               ->select();
		
		return $result;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	//舍去
	function getlist2(){
		$subtable = $this->subTableName;
		$cash = $this->select(false);
		$result = $this->table("$cash a")->field("a.*,b.username,b.name")
					   ->join("$subtable b on a.uid = b.uid")
					   ->select();
		
		//今日处理订单特殊标记
		/*
		foreach($result as $k=>$v) {
			if($v['dtime']>date('Y-m-d 00:00:00')) {
				$result[$k]['today'] = 1;
			}else{
				$result[$k]['today'] = 0;
			}
		}
		*/
		
		return $result;
	}
	
	
	//舍去
	function getlist3(){
		$subtable = $this->subTableName;
		$cash = $this->select(false);
		$result = $this->table("$cash a")->field("a.*,b.username,b.name")
		               ->join("$subtable b on a.uid = b.uid")
		               ->where("a.uid <> 0")
		               ->select();
		
		$subtable2 = $this->subTableName2;
		$result2 = $this->table("$cash a")->field("a.*,b.mobile as username,b.name")
		                ->join("$subtable2 b on a.cid = b.cid")
		                ->where("a.cid <> 0")
		                ->select();
		
		$result = array_merge($result2,$result);
		
		return $result;
	}
	
	
	
}

?>